
//
//  HomeVideoTool.m
//  Fireball
//
//  Created by 俞渊华 on 2017/12/25.
//  Copyright © 2017年 俞渊华. All rights reserved.
//

#import "HomeVideoTool.h"

@interface HomeVideoTool ()
@property(nonatomic, strong)UILabel *titleLabel;

@property(nonatomic, strong)UIButton * attentionButton;
@property(nonatomic, strong)UIButton *moreButton;
@property(nonatomic, strong)UIButton *messaegButton;

@end

@implementation HomeVideoTool

-(instancetype)initWithFrame:(CGRect)frame{
    if ([super initWithFrame:frame]) {
        self.backgroundColor = [UIColor whiteColor];
        
        self.titleLabel = [[UILabel alloc] init];
        self.titleLabel.font = [UIFont xm_medium:15.0];
        self.titleLabel.textColor = [UIColor xm_jetblackColor];
        [self addSubview:self.titleLabel];
        
        self.attentionButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.attentionButton setTitle:@"+关注" forState:UIControlStateNormal];
        [self.attentionButton setTitle:@"已关注" forState:UIControlStateSelected];
        [self.attentionButton setTitleColor:[UIColor xm_MainColor] forState:UIControlStateNormal];
        [self.attentionButton setTitleColor:[UIColor xm_somberColor] forState:UIControlStateNormal];
        self.attentionButton.titleLabel.font = [UIFont xm_font:13.0];
        self.attentionButton.layer.masksToBounds = YES;
        self.attentionButton.layer.borderWidth = 1.0;
        self.attentionButton.layer.cornerRadius = 12.0;
        [self addSubview:self.attentionButton];
        
        self.moreButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.moreButton setImage:[UIImage imageNamed:@"news_more"] forState:UIControlStateNormal];
        [self addSubview:self.moreButton];
        
        self.messaegButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.messaegButton setImage:[UIImage imageNamed:@"news_more"] forState:UIControlStateNormal];
        [self.messaegButton setTitle:@" 14" forState:UIControlStateNormal];
        [self.messaegButton setTitleColor:[UIColor xm_somberColor] forState:UIControlStateNormal];
        self.messaegButton.titleLabel.font = [UIFont xm_font:11.0];
//        self.messaegButton
        [self addSubview:self.messaegButton];
    }
    return self;
}
-(void)setModel:(AticleModel *)model{
    _model = model;
    self.titleLabel.text = _model.Souce;
    if (self.attentionButton.selected) {
        self.attentionButton.layer.borderColor = [UIColor xm_MainColor].CGColor;
    }else{
        self.attentionButton.layer.borderColor = [UIColor xm_somberColor].CGColor;
    }
}
-(void)layoutSubviews{
    [super layoutSubviews];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self);
        make.left.mas_equalTo(self).offset(15);
    }];
    
    [self.attentionButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.titleLabel.mas_right).offset(10);
        make.centerY.mas_equalTo(self);
        make.size.mas_equalTo(CGSizeMake(60, 24));
    }];
    
    [self.moreButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self);
        make.right.mas_equalTo(self).offset(-20);
        make.height.mas_equalTo(@30);
    }];
    [self.messaegButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self);
        make.right.mas_equalTo(self.moreButton.mas_left).offset(-20);
        make.height.mas_equalTo(@30);
    }];
}
-(void)drawRect:(CGRect)rect{
    [super drawRect:rect];
}


@end
